Skip to main content

find

Type

command

Summary

Searches the fields of the current stack.

Syntax

find [<form>] <textToFind> [in <field>]
find empty

Description

Use the find command to search for text.

The find command starts searching after the previously-found text (if there was a previous find command) or at the beginning of the first field on the current card (if not).

The six forms of the find command search in different ways. The find normal, find chars, and find words forms search for each word in the textToFind, but the words don't have to be together to be found; they only have to all appear on the same card. The find words and find wholeforms look for complete words only. The find string and find whole forms search for the textToFind as a unit.

The find normal form looks for each word in the textToFind at the beginning of a word. For example, find "ring bell" finds "ringing" and "belltower", but not "bring" or "Campbell". All the words you specify must be in fields on the card, but they don't need to be in the same order, or even in the same field.

The find chars form looks for each word in the textToFind, in any part of a word. Unlike the find normal form, the find chars form doesn't require that the words in the textToFind be found at the start of a word on the card. For example, find chars "ring bell" finds "bring", "ringing", "belltower", and "Campbell". As with the find normal form, all the words must be somewhere on the card, but they don't need to be in the same order, or in the same field.

The find words form looks for each word in the textToFind. All the words must be complete words, not parts of words. For example, find words "ring bell" finds "ring" and "bell", but not "ringing", "bring", "belltower", or "Campbell". As with the find normal and find chars forms, all the words must be somewhere on the card, but they don't need to be in the same order, or in the same field.

The find string form looks for the entire textToFind as a unit. Unlike the find normal, find chars, and find words forms, the find string form requires that the textToFind be found exactly: the words must be in the same order and in the same field, and not separated by other words. For example, find string "ring bell" finds "ring bell" and "bring belltower", but not "ring the bell" (extra word between "ring" and "bell" ), "Ringbell Street" (no space between "ring" and "bell" ), or "bell ringer" (words are in the wrong order).

The find whole form looks for the entire textToFind as a unit. Like the find words form (and unlike the find string form), the find whole form requires that each word in the textToFind be found as a whole word, not part of a word. For example, find whole "ring bell" finds "ring bell", but not "bring belltower" (the "ring" and "bell" are parts of words, not whole words), "ring the bell" (extra word between "ring" and "bell" ), "Ringbell Street" (no space between "ring" and "bell" ), or "bell ringer" (words are in the wrong order).

note

Because the find normal, find words, and find whole forms search for words or portions of words, they cannot find a string containing a space. The find string form can find a string containing a space, but cannot find a string that contains a return character.

The find empty form of the find command removes the box from the last word found and resets the find command, so that the next search starts from the beginning of the current card, rather than the location of the next find. Going to another card also resets the find command.

The setting of the caseSensitive property determines whether the search considers uppercase and lowercase characters to be equivalent.

note

The search does not consider characters that differ by a diacritical mark to be equivalent. For example, find "mére" will not find the word "mere".

Usually, the offset and matchText functions are faster than the find command. But unlike these functions, the find command can search all the fields of a stack at once, instead of one container at a time.

tip

To perform a batch search, set the mark property of all cards where a match is found by using the mark cards by finding form of the mark command.

Parameters

NameTypeDescription

form

enum

If no form is specified, the normal form is used.

textToFind

string

field

Any expression that evaluates to a field reference. If the field is not specified, the find command searches all the fields in the current stack (except fields whose dontSearch property is set to true).

Examples

find "heart"
find string "beat must go on" in field "Quotes"

command: replace, unmark, sort, mark

constant: return

control structure: function

function: foundChunk, foundField, offset, matchText, foundText, foundLine, foundLoc

glossary: property, current card, reset, return, container, function, command, current stack

keyword: normal, whole, characters, string, character, the, words, word, card, field

object: field, stack, card

property: caseSensitive, dontSearch, mark

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?